<div style="padding:20px 0 20px 80px">
    <form action="#" id="selectArea" method="post">
        <ul id="operation"></ul>
    </form>
</div>

<script>
    var checkedArea = [];
    var defaultAreaList = {php}echo $data;{/php};
    layui.use(['tree2','form','jquery'], function() {
        var tree = layui.tree2({
            elem: '#operation', //指定元素，生成的树放到哪个元素上
            check: 'checkbox', //勾选风格
            skin: 'as', //设定皮肤
            drag: true,//点击每一项时是否生成提示信息
            checkboxName: 'operation_id[]',//复选框的name属性值
            checkboxStyle: "",//设置复选框的样式，必须为字符串，css样式怎么写就怎么写
            click: function(item) { //点击节点回调
            },
            onchange: function (){
            },
            nodes: defaultAreaList
        });
    });

    function getAllChecked() {
        if($('input:checkbox:checked').length>0){
            $.each($('input:checkbox:checked'),function(){
                var pid = $(this).attr('data-parent-value');
                if(typeof(pid)!='undefined'&&pid!=''&&typeof(pid)!='null'){
                    var tempData = {'id':$(this).val()};
                    checkedArea.push(tempData);
                }
            });
        }else{
            parent.layer.msg("请先选择操作权限");
            return false;
        }
        return checkedArea;
    }
</script>

